<template>
 <div style="display: flex;justify-content: space-between">
<h2>教师管理</h2>
        <h2><button @click="go2add()">添加教师</button></h2>
    </div>
    <div style="display: flex">
        <div style="width: 90%;border: blue 1px solid">
            <h2 style="text-align: center">教师显示</h2>
            <table border="1" style="width: 100%">
                <tr>
                    <th>编号</th>
                    <th>名字</th>
                    <th>账号</th>
                    <!-- <th>密码</th> -->
                    <th>图片</th>
                    <th>操作</th>
                </tr>
                <tr v-for="x,idx in teas" @click="go2up(x.uid)"  :class="{c:tea.uid==x.uid}">
                    <th>{{x.uid}}</th>
                    <th>{{x.uname}}</th>
                    <th>{{x.phone}}</th>
                    <!-- <th>{{x.pwd}}</th> -->
                    <th><div style="width: 60px;height: 13vh;">
                        <img v-bind:src="$ip+`/api/public/showimg/`+x.pic" style="width: 100% ;height: 100%">
                    </div></th>
                    <th><button @click="del(x.uid)">删除</button></th>
                </tr>
            </table>
        </div>
		 
	</div>
</template>


<script>
	export default{
		data(){
			return{
				teas:[],
				tea:{}
			}
		},
		methods:{
			go2add(){
				this.$router.push({
					path:'/adm/teaadd',query:{
						id:0
					}
					
				})
			},
			go2up(uid){
				this.$router.push({
					path:'/adm/teaadd',query:{
						id:uid
					}
				})
			},
			del(uid){
				var that=this
				var a=this.$ip+"/api/adm/tea/del?uid="+uid
				this.$axios.get(a,{headers:{'Authorization':that.token}}).then(function(resp){
					that.teas=resp.data.data
					console.log(resp.data.data)
				})
			}
		},
		mounted() {
			var that=this
			that.token=window.localStorage.getItem("token")
			var a=this.$ip+"/api/adm/tea/findAll"
			this.$axios.get(a,{headers:{'Authorization':that.token}}).then(function(resp){
				that.teas=resp.data.data
				console.log(resp.data.data)
			})
		}
	}
</script>

<style>
</style>
